#include<iostream>
#include<algorithm>
#include<cstring>
#include<unordered_set>
#include<set>
#include<map>
using namespace std;
typedef long long LL;
const int N = 1e5 + 10, M = 2e5 + 10;
int h[N], e[M], ne[M], idx;
bool flag;
bool st[N];
int n, m;
void add(int a, int b)
{
	e[idx] = b, ne[idx] = h[a], h[a] = idx++;
}
bool dfs(int u, int fa)
{
	//cout << "u==" << u << endl;
	st[u] = 1;
	for (int i = h[u]; ~i; i = ne[i]) {
		int j = e[i];
		//cout << "j===" << j << endl;
		if (j == fa) continue;
		if (!st[j]) {
			dfs(j, u);
		}
		else {
			flag = 1;
			continue;
		}
	}
	return 1;
}
int main()
{
	cin >> n >> m;
	memset(h, -1, sizeof(h));
	while (m--) {
		int a, b;
		cin >> a >> b;
		add(a, b);
		add(b, a);
	}
	/*for (int i = h[4]; ~i; i = ne[i]) {
		cout << e[i] << endl;
	}*/
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		flag = 0;
		if (!st[i]) {
			dfs(i, -1);
			if (!flag)ans++;
		}
	}
	cout << ans << endl;
	return 0;
}